LIB_DIR = ../lib
INCLUDE = -I../include -I./utils
CFLAGS = -O0 -g3 -static
CFLAGS += -mhard-float -mcpu=ck860fv
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
CFLAGS += -DCSINN_API=0	# params.api = CSINN_API = CSINN_REF = 0
LIB_NAME = csi_nn2_ref
CC = csky-abiv2-linux-gcc

test_objs =

test_objs += validation/sin_f32.o
test_objs += validation/sin_u8.o
test_objs += validation/sin_i8.o
test_objs += validation/sinh_f32.o
test_objs += validation/sinh_u8.o
test_objs += validation/sinh_i8.o
test_objs += validation/asin_f32.o
test_objs += validation/asin_u8.o
test_objs += validation/asin_i8.o
test_objs += validation/asinh_f32.o
test_objs += validation/asinh_u8.o
test_objs += validation/asinh_i8.o
test_objs += validation/cos_f32.o
test_objs += validation/cos_u8.o
test_objs += validation/cos_i8.o
test_objs += validation/cosh_f32.o
test_objs += validation/cosh_u8.o
test_objs += validation/cosh_i8.o
test_objs += validation/acos_f32.o
test_objs += validation/acos_u8.o
test_objs += validation/acos_i8.o
test_objs += validation/acosh_f32.o
test_objs += validation/acosh_u8.o
test_objs += validation/acosh_i8.o
test_objs += validation/tan_f32.o
test_objs += validation/tan_u8.o
test_objs += validation/tan_i8.o
test_objs += validation/tanh_f32.o
test_objs += validation/tanh_u8.o
test_objs += validation/tanh_i8.o
test_objs += validation/atan_f32.o
test_objs += validation/atan_u8.o
test_objs += validation/atan_i8.o
test_objs += validation/atanh_f32.o
test_objs += validation/atanh_u8.o
test_objs += validation/atanh_i8.o

test_objs += validation/abs_f32.o
test_objs += validation/abs_u8.o
test_objs += validation/abs_i8.o
test_objs += validation/pow_f32.o
test_objs += validation/pow_u8.o
test_objs += validation/pow_i8.o
test_objs += validation/mul_f32.o
test_objs += validation/mul_u8.o
test_objs += validation/mul_i8.o
test_objs += validation/add_f32.o
test_objs += validation/add_u8.o
test_objs += validation/add_i8.o
test_objs += validation/sub_f32.o
test_objs += validation/sub_u8.o
test_objs += validation/sub_i8.o
test_objs += validation/div_f32.o
test_objs += validation/div_u8.o
test_objs += validation/div_i8.o
test_objs += validation/greater_f32.o
test_objs += validation/greater_u8.o
test_objs += validation/greater_i8.o
test_objs += validation/less_f32.o
test_objs += validation/less_u8.o
test_objs += validation/less_i8.o
test_objs += validation/less_equal_f32.o
test_objs += validation/less_equal_u8.o
test_objs += validation/less_equal_i8.o
test_objs += validation/equal_f32.o
test_objs += validation/equal_u8.o
test_objs += validation/equal_i8.o
test_objs += validation/logical_and_f32.o
test_objs += validation/logical_and_u8.o
test_objs += validation/logical_and_i8.o
test_objs += validation/logical_or_f32.o
test_objs += validation/logical_or_u8.o
test_objs += validation/logical_or_i8.o
test_objs += validation/logical_not_f32.o
test_objs += validation/logical_not_u8.o
test_objs += validation/logical_not_i8.o
test_objs += validation/logical_xor_f32.o
test_objs += validation/logical_xor_u8.o
test_objs += validation/logical_xor_i8.o
test_objs += validation/log1p_f32.o
test_objs += validation/log1p_u8.o
test_objs += validation/log1p_i8.o
test_objs += validation/expm1_f32.o
test_objs += validation/expm1_u8.o
test_objs += validation/expm1_i8.o
test_objs += validation/greater_equal_f32.o
test_objs += validation/greater_equal_u8.o
test_objs += validation/greater_equal_i8.o
test_objs += validation/not_equal_f32.o
test_objs += validation/not_equal_u8.o
test_objs += validation/not_equal_i8.o
test_objs += validation/floor_div_f32.o
test_objs += validation/floor_div_u8.o
test_objs += validation/floor_div_i8.o
test_objs += validation/floor_mod_f32.o
test_objs += validation/floor_mod_u8.o
test_objs += validation/floor_mod_i8.o
test_objs += validation/mod_f32.o
test_objs += validation/mod_u8.o
test_objs += validation/mod_i8.o
test_objs += validation/elu_f32.o
test_objs += validation/elu_u8.o
test_objs += validation/elu_i8.o
test_objs += validation/fullyconnected_f32.o
test_objs += validation/fullyconnected_u8.o
test_objs += validation/fullyconnected_i8.o
test_objs += validation/relu_f32.o
test_objs += validation/relu_u8.o
test_objs += validation/relu_i8.o
test_objs += validation/relu6_f32.o
test_objs += validation/relu6_u8.o
test_objs += validation/relu6_i8.o
test_objs += validation/relu1_f32.o
test_objs += validation/relu1_u8.o
test_objs += validation/relu1_i8.o
test_objs += validation/relun_f32.o
test_objs += validation/relun_u8.o
test_objs += validation/relun_i8.o
test_objs += validation/rsqrt_f32.o
test_objs += validation/rsqrt_u8.o
test_objs += validation/rsqrt_i8.o
test_objs += validation/resize_bilinear_f32.o
test_objs += validation/resize_bilinear_u8.o
test_objs += validation/resize_bilinear_i8.o
test_objs += validation/resize_nearestneighbor_f32.o
test_objs += validation/resize_nearestneighbor_u8.o
test_objs += validation/resize_nearestneighbor_i8.o
test_objs += validation/resize_nearestneighbor_nchw_u8.o
test_objs += validation/resize_nearestneighbor_nchw_i8.o
test_objs += validation/sigmoid_f32.o
test_objs += validation/sigmoid_u8.o
test_objs += validation/sigmoid_i8.o
test_objs += validation/hard_sigmoid_f32.o
test_objs += validation/hard_sigmoid_i8.o
test_objs += validation/hard_sigmoid_u8.o
test_objs += validation/softmax_f32.o
test_objs += validation/softmax_u8.o
test_objs += validation/softmax_i8.o
test_objs += validation/log_softmax_f32.o
test_objs += validation/log_softmax_u8.o
test_objs += validation/log_softmax_i8.o
test_objs += validation/sqrt_f32.o
test_objs += validation/sqrt_u8.o
test_objs += validation/sqrt_i8.o
test_objs += validation/select_f32.o
test_objs += validation/select_u8.o
test_objs += validation/select_i8.o
test_objs += validation/leaky_relu_f32.o
test_objs += validation/leaky_relu_u8.o
test_objs += validation/leaky_relu_i8.o
test_objs += validation/prelu_f32.o
test_objs += validation/prelu_u8.o
test_objs += validation/prelu_i8.o
test_objs += validation/prelu_nhwc_f32.o
test_objs += validation/prelu_nhwc_u8.o
test_objs += validation/prelu_nhwc_i8.o
test_objs += validation/floor_f32.o
test_objs += validation/floor_u8.o
test_objs += validation/floor_i8.o

test_objs += validation/convolution_f32.o
test_objs += validation/convolution_u8.o
test_objs += validation/convolution_i8.o
test_objs += validation/convolution_relu_u8.o
test_objs += validation/convolution_relu_i8.o
test_objs += validation/convolution_relu6_u8.o
test_objs += validation/convolution_relu6_i8.o
test_objs += validation/convolution_relu_nchw_u8.o
test_objs += validation/convolution_relu_nchw_i8.o
test_objs += validation/convolution_nchw_f32.o
test_objs += validation/convolution_nchw_u8.o
test_objs += validation/convolution_nchw_i8.o
test_objs += validation/convolution_relu6_nchw_u8.o
test_objs += validation/convolution_relu6_nchw_i8.o
test_objs += validation/convolution3d_f32.o
test_objs += validation/convolution3d_u8.o
test_objs += validation/convolution3d_i8.o
#test_objs += validation/convolution_channel_nchw_u8.o
#test_objs += validation/convolution_channel_nchw_i8.o
test_objs += validation/group_convolution_f32.o
test_objs += validation/group_convolution_u8.o
test_objs += validation/group_convolution_i8.o
test_objs += validation/group_convolution_nchw_u8.o
test_objs += validation/group_convolution_nchw_i8.o
test_objs += validation/group_convolution_relu_u8.o
test_objs += validation/group_convolution_relu_i8.o
test_objs += validation/group_convolution_relu_nchw_u8.o
test_objs += validation/group_convolution_relu_nchw_i8.o
test_objs += validation/group_convolution_relu6_u8.o
test_objs += validation/group_convolution_relu6_i8.o
test_objs += validation/group_convolution_relu6_nchw_u8.o
test_objs += validation/group_convolution_relu6_nchw_i8.o
test_objs += validation/depthwise_convolution_f32.o
test_objs += validation/depthwise_convolution_u8.o
test_objs += validation/depthwise_convolution_i8.o
test_objs += validation/depthwise_convolution_nchw_f32.o
test_objs += validation/depthwise_convolution_nchw_u8.o
test_objs += validation/depthwise_convolution_nchw_i8.o
test_objs += validation/depthwise_convolution_relu_u8.o
test_objs += validation/depthwise_convolution_relu_i8.o
test_objs += validation/depthwise_convolution_relu_nchw_u8.o
test_objs += validation/depthwise_convolution_relu_nchw_i8.o
test_objs += validation/depthwise_convolution_relu6_u8.o
test_objs += validation/depthwise_convolution_relu6_i8.o
test_objs += validation/depthwise_convolution_relu6_nchw_u8.o
test_objs += validation/depthwise_convolution_relu6_nchw_i8.o
test_objs += validation/depthwise_deconvolution_u8.o
test_objs += validation/depthwise_deconvolution_i8.o
test_objs += validation/deconvolution3d_f32.o
test_objs += validation/deconvolution_u8.o
test_objs += validation/deconvolution_i8.o
test_objs += validation/deconvolution_nchw_u8.o
test_objs += validation/deconvolution_nchw_i8.o

test_objs += validation/yuv_rgb_scale_f32.o
test_objs += validation/yuv_rgb_scale_u8.o
test_objs += validation/yuv_rgb_scale_i8.o
test_objs += validation/unsorted_segment_max_f32.o
test_objs += validation/unsorted_segment_max_u8.o
test_objs += validation/unsorted_segment_max_i8.o
test_objs += validation/segment_max_f32.o
test_objs += validation/segment_max_u8.o
test_objs += validation/segment_max_i8.o
test_objs += validation/unsorted_segment_min_f32.o
test_objs += validation/unsorted_segment_min_u8.o
test_objs += validation/unsorted_segment_min_i8.o
test_objs += validation/segment_min_f32.o
test_objs += validation/segment_min_u8.o
test_objs += validation/segment_min_i8.o
test_objs += validation/unsorted_segment_sum_f32.o
test_objs += validation/unsorted_segment_sum_u8.o
test_objs += validation/unsorted_segment_sum_i8.o
test_objs += validation/segment_sum_f32.o
test_objs += validation/segment_sum_u8.o
test_objs += validation/segment_sum_i8.o
test_objs += validation/unsorted_segment_mean_f32.o
test_objs += validation/unsorted_segment_mean_u8.o
test_objs += validation/unsorted_segment_mean_i8.o
test_objs += validation/segment_mean_f32.o
test_objs += validation/segment_mean_u8.o
test_objs += validation/segment_mean_i8.o
test_objs += validation/unsorted_segment_prod_f32.o
test_objs += validation/unsorted_segment_prod_u8.o
test_objs += validation/unsorted_segment_prod_i8.o
test_objs += validation/segment_prod_f32.o
test_objs += validation/segment_prod_u8.o
test_objs += validation/segment_prod_i8.o
test_objs += validation/threshold_relu_f32.o
test_objs += validation/threshold_relu_u8.o
test_objs += validation/threshold_relu_i8.o
test_objs += validation/matmul_f32.o
test_objs += validation/matmul_u8.o
test_objs += validation/matmul_i8.o
test_objs += validation/batch_norm_f32.o
test_objs += validation/batch_norm_u8.o
test_objs += validation/batch_norm_i8.o
test_objs += validation/l2_norm_f32.o
test_objs += validation/l2_norm_u8.o
test_objs += validation/l2_norm_i8.o

test_objs += validation/cumsum_f32.o
test_objs += validation/cumsum_u8.o
test_objs += validation/cumsum_i8.o
test_objs += validation/cumprod_f32.o
test_objs += validation/cumprod_u8.o
test_objs += validation/cumprod_i8.o
test_objs += validation/reduce_max_f32.o
test_objs += validation/reduce_max_u8.o
test_objs += validation/reduce_max_i8.o
test_objs += validation/reduce_min_f32.o
test_objs += validation/reduce_min_u8.o
test_objs += validation/reduce_min_i8.o
test_objs += validation/reduce_sum_f32.o
test_objs += validation/reduce_prod_f32.o
test_objs += validation/reduce_prod_u8.o
test_objs += validation/reduce_prod_i8.o
test_objs += validation/reduce_mean_f32.o
test_objs += validation/reduce_mean_u8.o
test_objs += validation/reduce_mean_i8.o
test_objs += validation/reduce_logsumexp_f32.o
test_objs += validation/reduce_logsumexp_u8.o
test_objs += validation/reduce_logsumexp_i8.o
test_objs += validation/softplus_f32.o
test_objs += validation/softplus_u8.o
test_objs += validation/softplus_i8.o
test_objs += validation/softsign_f32.o
test_objs += validation/softsign_u8.o
test_objs += validation/softsign_i8.o
test_objs += validation/squeeze_f32.o
test_objs += validation/squeeze_u8.o
test_objs += validation/squeeze_i8.o
test_objs += validation/broadcast_to_f32.o
test_objs += validation/broadcast_to_u8.o
test_objs += validation/broadcast_to_i8.o
test_objs += validation/clip_f32.o
test_objs += validation/clip_u8.o
test_objs += validation/clip_i8.o
test_objs += validation/expand_dims_f32.o
test_objs += validation/expand_dims_u8.o
test_objs += validation/expand_dims_i8.o
test_objs += validation/reverse_f32.o
test_objs += validation/reverse_u8.o
test_objs += validation/reverse_i8.o
test_objs += validation/depth_to_space_f32.o
test_objs += validation/depth_to_space_u8.o
test_objs += validation/depth_to_space_i8.o
test_objs += validation/space_to_depth_f32.o
test_objs += validation/space_to_depth_u8.o
test_objs += validation/space_to_depth_i8.o
test_objs += validation/tile_f32.o
test_objs += validation/tile_u8.o
test_objs += validation/tile_i8.o
test_objs += validation/stack_f32.o
test_objs += validation/stack_u8.o
test_objs += validation/stack_i8.o
test_objs += validation/unstack_f32.o
test_objs += validation/unstack_u8.o
test_objs += validation/unstack_i8.o
test_objs += validation/strided_slice_f32.o
test_objs += validation/strided_slice_u8.o
test_objs += validation/strided_slice_i8.o
test_objs += validation/batch_to_space_f32.o
test_objs += validation/batch_to_space_u8.o
test_objs += validation/batch_to_space_i8.o
test_objs += validation/space_to_batch_f32.o
test_objs += validation/space_to_batch_u8.o
test_objs += validation/space_to_batch_i8.o
test_objs += validation/gather_f32.o
test_objs += validation/gather_u8.o
test_objs += validation/gather_i8.o
test_objs += validation/gather_nd_f32.o
test_objs += validation/gather_nd_u8.o
test_objs += validation/gather_nd_i8.o
test_objs += validation/topk_f32.o
test_objs += validation/topk_u8.o
test_objs += validation/topk_i8.o
test_objs += validation/non_max_suppression_f32.o
test_objs += validation/shuffle_channel_f32.o
test_objs += validation/shuffle_channel_u8.o
test_objs += validation/shuffle_channel_i8.o
test_objs += validation/im2col_f32.o
test_objs += validation/im2col_u8.o
test_objs += validation/im2col_i8.o

test_objs += validation/averagepool3d_f32.o
test_objs += validation/averagepool3d_u8.o
test_objs += validation/averagepool3d_i8.o
test_objs += validation/maxpool3d_f32.o
test_objs += validation/maxpool3d_u8.o
test_objs += validation/maxpool3d_i8.o
test_objs += validation/maxpool_f32.o
test_objs += validation/maxpool_nchw_f32.o
test_objs += validation/averagepool_f32.o
test_objs += validation/averagepool_u8.o
test_objs += validation/averagepool_i8.o
test_objs += validation/averagepool_nchw_f32.o
test_objs += validation/averagepool_nchw_u8.o
test_objs += validation/averagepool_nchw_i8.o
test_objs += validation/global_avgpool_u8.o
test_objs += validation/global_avgpool_i8.o
test_objs += validation/global_avgpool_nchw_u8.o
test_objs += validation/global_avgpool_nchw_i8.o
test_objs += validation/global_maxpool_u8.o
test_objs += validation/global_maxpool_i8.o
test_objs += validation/global_maxpool_nchw_u8.o
test_objs += validation/global_maxpool_nchw_i8.o

test_objs += validation/concat_f32.o
test_objs += validation/concat_u8.o
test_objs += validation/concat_i8.o
test_objs += validation/erf_f32.o
test_objs += validation/erf_u8.o
test_objs += validation/erf_i8.o
test_objs += validation/arange_f32.o
test_objs += validation/arange_u8.o
test_objs += validation/arange_i8.o
test_objs += validation/ceil_f32.o
test_objs += validation/ceil_u8.o
test_objs += validation/ceil_i8.o

test_objs += validation/exp_f32.o
test_objs += validation/exp_u8.o
test_objs += validation/exp_i8.o
test_objs += validation/flatten_f32.o
test_objs += validation/flatten_u8.o
test_objs += validation/flatten_i8.o
test_objs += validation/is_nan_f32.o
test_objs += validation/log_f32.o
test_objs += validation/log_u8.o
test_objs += validation/log_i8.o
test_objs += validation/lrn_f32.o
test_objs += validation/lrn_u8.o
test_objs += validation/lrn_i8.o

test_objs += validation/maximum_f32.o
test_objs += validation/maximum_u8.o
test_objs += validation/maximum_i8.o
test_objs += validation/minimum_f32.o
test_objs += validation/minimum_u8.o
test_objs += validation/minimum_i8.o
test_objs += validation/ndarray_size_f32.o
test_objs += validation/ndarray_size_u8.o
test_objs += validation/ndarray_size_i8.o
test_objs += validation/negative_f32.o
test_objs += validation/negative_u8.o
test_objs += validation/negative_i8.o
test_objs += validation/not_f32.o
test_objs += validation/reshape_f32.o
test_objs += validation/round_f32.o
test_objs += validation/round_u8.o
test_objs += validation/round_i8.o
test_objs += validation/slice_f32.o
test_objs += validation/slice_u8.o
test_objs += validation/slice_i8.o
test_objs += validation/softrelu_f32.o
test_objs += validation/softrelu_u8.o
test_objs += validation/softrelu_i8.o
test_objs += validation/square_f32.o

test_objs += validation/transpose_f32.o
test_objs += validation/transpose_u8.o
test_objs += validation/transpose_i8.o
test_objs += validation/trunc_f32.o
test_objs += validation/trunc_u8.o
test_objs += validation/trunc_i8.o

# test_objs += validation/dequantize_f32.o

utils_objs =

utils_objs += utils/math_snr.o
utils_objs += utils/test_utils.o

all: csi

csi: $(utils_objs) $(test_objs)

$(utils_objs): %.o: %.c
	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@

$(test_objs): %.o: %.c
	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
	$(CC) $@ $(CFLAGS) $(BOARD) $(utils_objs) -L$(LIB_DIR) -l$(LIB_NAME) -lc -lm -o $@.elf

clean:
	rm -rf  *.a *.asm validation/*.elf validation/*.o validation/*.bin validation/*.asm utils/*.o
